import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import user from './modules/user'
import cart from './modules/cart'
import cartgory from './modules/cartgory'

export default createStore({
  state: {},
  getters: {
    token: () => user.state().profile.token,
    menuList: () => cartgory.state(),
  },
  mutations: {},
  actions: {},
  modules: {
    user,
    cart,
    cartgory,
  },
  // 配置插件
  plugins: [
    // 默认存储在 localstorage
    createPersistedState({
      // 本地存储名字
      key: 'shop-prject',
      // 指定需要存储的模块
      paths: ['user', 'cart'],
    }),
  ],
})
